#define _CRT_SECURE_NO_WARNINGS 1

#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

map<int, vector<int>> m;
int n;

int exec(int l, int r, int a)
{
    if (m[a].size() == 0)    return 0;
    auto it1 = lower_bound(m[a].begin(), m[a].end(), l);
    auto it2 = upper_bound(m[a].begin(), m[a].end(), r);
    return it2 - it1;
}

int main()
{
    cin >> n;
    int a;
    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        m[a].push_back(i);
    }

    int q;
    cin >> q;
    int l, r;
    while (q--)
    {
        cin >> l >> r >> a;
        cout << exec(l, r, a) << endl;
    }
    return 0;
}